package com.connection.second.wallpaper.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.connection.second.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.connection.second.common.annotation.Log;
import com.connection.second.common.core.controller.BaseController;
import com.connection.second.common.core.domain.AjaxResult;
import com.connection.second.common.enums.BusinessType;
import com.connection.second.wallpaper.domain.entity.PaperHomeBanner;
import com.connection.second.wallpaper.service.IPaperHomeBannerService;
import com.connection.second.common.utils.poi.ExcelUtil;
import com.connection.second.common.core.page.TableDataInfo;

/**
 * 首页海报管理Controller
 * 
 * @author FL
 * @date 2024-11-15
 */
@RestController
@RequestMapping("/wallpaper/banner")
public class PaperHomeBannerController extends BaseController
{
    @Autowired
    private IPaperHomeBannerService paperHomeBannerService;

    /**
     * 查询首页海报管理列表
     */
//    @PreAuthorize("@ss.hasPermi('wallpaper:banner:list')")
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(PaperHomeBanner paperHomeBanner)
    {
        startPage();
        List<PaperHomeBanner> list = paperHomeBannerService.selectPaperHomeBannerList(paperHomeBanner);
        return getDataTable(list);
    }



    /**
     * 导出首页海报管理列表
     */
    @PreAuthorize("@ss.hasPermi('wallpaper:banner:export')")
    @Log(title = "首页海报管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PaperHomeBanner paperHomeBanner)
    {
        List<PaperHomeBanner> list = paperHomeBannerService.selectPaperHomeBannerList(paperHomeBanner);
        ExcelUtil<PaperHomeBanner> util = new ExcelUtil<PaperHomeBanner>(PaperHomeBanner.class);
        util.exportExcel(response, list, "首页海报管理数据");
    }

    /**
     * 获取首页海报管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('wallpaper:banner:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(paperHomeBannerService.selectPaperHomeBannerById(id));
    }

    /**
     * 新增首页海报管理
     */
    @PreAuthorize("@ss.hasPermi('wallpaper:banner:add')")
    @Log(title = "首页海报管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PaperHomeBanner paperHomeBanner)
    {
        return toAjax(paperHomeBannerService.insertPaperHomeBanner(paperHomeBanner));
    }

    /**
     * 修改首页海报管理
     */
    @PreAuthorize("@ss.hasPermi('wallpaper:banner:edit')")
    @Log(title = "首页海报管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PaperHomeBanner paperHomeBanner)
    {
        return toAjax(paperHomeBannerService.updatePaperHomeBanner(paperHomeBanner));
    }

    /**
     * 删除首页海报管理
     */
    @PreAuthorize("@ss.hasPermi('wallpaper:banner:remove')")
    @Log(title = "首页海报管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(paperHomeBannerService.deletePaperHomeBannerByIds(ids));
    }
}
